package com.xyz.service;

import com.free.exception.SystemException;
import com.xyz.dao.logic.SLotteryPeriodLogic;
import com.xyz.domain.constants.EhCacheConstants;
import com.xyz.domain.model.LotteryInfoModel;
import com.xyz.domain.table.SLotteryPeriod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LotteryTrendencyService extends BaseService{

    @Autowired
    private SLotteryPeriodLogic lotteryPeriodLogic;

    public LotteryInfoModel lotteryinfoModel(String lotteryCode) throws SystemException {
        return getObjectFromCache(EhCacheConstants.LotteryTrendencyCache,lotteryCode, LotteryInfoModel.class);
    }

    public void cacheSafety(String lotteryCode){
        Cache cache = ehCacheCacheManager.getCache(EhCacheConstants.LotteryTrendencyCache);
        if(cache != null){
            cache.put(lotteryCode, genLotteryTrendency(lotteryCode));
        }
    }

    private LotteryInfoModel genLotteryTrendency(String lotteryCode){
        List<SLotteryPeriod> periods = lotteryPeriodLogic.getTop400Info(lotteryCode);


        return null;
    }


}
